<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>数据爬取</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/4.3.1/css/bootstrap.min.css">
    <script src="https://cdn.staticfile.org/jquery/3.2.1/jquery.min.js"></script>
    <script src="https://cdn.staticfile.org/popper.js/1.15.0/umd/popper.min.js"></script>
    <script src="https://cdn.staticfile.org/twitter-bootstrap/4.3.1/js/bootstrap.min.js"></script>
    <script src="https://cdn.staticfile.org/echarts/4.3.0/echarts.min.js"></script>
</head>
<body>
<div class="container" id="app">


    <div class="jumbotron" style="margin-top: 200px">

        <h1 class="display-4">Boss直聘爬取!</h1>

        <p class="lead">由于网站反爬严重，本爬取需要时更多时间进行算法破解，请耐心等待！</p>
        <p class="lead" style="color: #4f8bf9">爬取时，可以在Pycharm中查看入库数据</p>
        <p class="lead" style="color: #e70032">每次的Cookis只能爬取4个页面，页面最好隔1-4页</p>
        <p class="lead">搜索全国: 100010000</p>
        <hr class="my-4">
        <div class="row">
            <input class="col" placeholder="请输入搜索城市代码 例: 100010000" v-model="city_code">
            <input class="col" placeholder="请输入爬取起始页数: 例: 1" v-model="start_page">
            <input class="col" placeholder="请输入爬取结束页数: 例: 4" v-model="stop_page">
            <button class="col btn btn-primary" @click="justdoit">提交</button>
        </div>
    </div>
</div>
</body>
</html>
<script src="https://cdn.staticfile.org/vue/2.2.2/vue.min.js"></script>
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
<script>
    var vm = new Vue({
        el: '#app',
        data: {
            city_code: "",
            start_page: "",
            stop_page: "",
        },
        created() {
        },
        methods: {
            justdoit() {
                alert("爬取开始，等待超时/请求网络失败请重新运行")
                axios.post('/run/main/', {
                    city_code: this.city_code,
                    start_page: this.start_page,
                    stop_page: this.stop_page,

                }).then(response => {
                    if (response.data['code'] == 200) {
                        alert("爬取成功,请查看 Boss直聘 模块")

                    } else if (response.data['code'] == 444) {
                        alert("您可能需要更新Cookies")
                    }
                }).catch(error => {
                    console.log(error)
                    alert("您可能需要更新Cookies")
                })
            }
        }

    })
</script>